package com.sikaryofficial.system.domain.dto;

import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.sikaryofficial.common.core.annotation.Excel;
import com.sikaryofficial.common.core.annotation.Excel.Type;
import com.sikaryofficial.common.core.annotation.LocalDateTimeFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.Date;
import java.util.Objects;

/**
 * 会员列表出参对象
 * 
 * @author qinjinyuan
 */
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Accessors(chain = true)
@Getter
@Setter
@ToString
@ApiModel(value = "会员列表出参对象", description = "会员列表出参对象")
public class SysMemberUserListDTO
{
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "名字")
    @Excel(name = "序号", width = 30,  type = Type.EXPORT)
    private Integer seqNo;

    @Excel(name = "姓名", width = 30,  type = Type.EXPORT)
    private String firstNameAndLastName;
    /** 名字 */
    @ApiModelProperty(value = "名字")
    private String firstName;
    /** 姓 */
    @ApiModelProperty(value = "姓")
    private String lastName;

    /** 创建时间 */
    @Excel(name = "创建时间" , dateFormat = "yyyy-MM-dd HH:mm:ss")
    @LocalDateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    /** 出生日期 */
    @LocalDateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "出生日期")
    private Date birthDate;

    /** 用户性别 */
    @Excel(name = "用户性别", readConverterExp = "0=male,1=female,2=Prefer not to say")
    @ApiModelProperty(value = "用户性别")
    private String sex;

    public String getSexDesc(){
        if(CharSequenceUtil.isBlank(sex) || "2".equals(sex)){
            return "Prefer not to say";
        }
        return "0".equals(sex)? "male" : "female";
    }

    /** 用户邮箱 */
    @Excel(name = "邮箱", width = 30,  type = Type.EXPORT)
    @ApiModelProperty(value = "用户邮箱")
    private String email;

    /** 用户ID */
    @ApiModelProperty(value = "用户ID")
    @Excel(name = "用户ID")
    private Long userId;

    /** 部门ID */
    private Long deptId;

    /** 手机号码 */
    @Excel(name = "手机号码")
    @ApiModelProperty(value = "手机号码")
    private String phoneNumber;

    /** 用户账号 */
    private String userName;

    /** 积分 */
    @Excel(name = "积分")
    private Long points;

    @Excel(name = "国家")
    @ApiModelProperty(value = "国家")
    private String country;

    /** 帐号状态（0正常 1停用） */
    @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
    @ApiModelProperty(value = "帐号状态（0正常 1停用）")
    private String status;

    public String getStatusDesc(){
        if(CharSequenceUtil.isBlank(status)){
            return null;
        }
        return "0".equals(status)? "normal" : "disabled";
    }
    @Excel(name = "年龄", width = 30,  type = Type.EXPORT)
    private Integer age;
    public Integer getAge(){
         if(Objects.isNull(birthDate)){
             return null;
         }
        return LocalDateTimeUtil.of(new Date()).getYear() - LocalDateTimeUtil.of(birthDate).getYear();
    }

}
